package cn.gwm.flink.streaming.strategy.vehiclepredict;

/**
 * @author : GW00280745
 * @date : 2023/1/15 13:09
 * @description :
 */
public class ChargePredictStrategy {



    /**
     * @description: 温度处理规则更新 只用max和min进行处理
     * @author:  GW00280745
     * @date: 2022/6/24 13:43
     * @param: tempMaxInt
     * @param: tempMinInt
     * @return: java.lang.Integer
     **/
    public Integer temp(Integer tempMaxInt,Integer tempMinInt){
        if (tempMaxInt== null || tempMinInt == null) {
            return null;
        }else if (tempMaxInt < tempMinInt){
            return null;
        }else if (tempMaxInt >=DwsStrConstant.ins().num25 && tempMaxInt <= DwsStrConstant.ins().num40 &&
                tempMinInt >=DwsStrConstant.ins().num25 && tempMinInt <= DwsStrConstant.ins().num40){
            return tempMinInt;
        }else if (tempMaxInt >= DwsStrConstant.ins().num25 && tempMaxInt <= DwsStrConstant.ins().num40 && tempMinInt < DwsStrConstant.ins().num25 ){
            return tempMinInt;
        }else if (tempMaxInt < DwsStrConstant.ins().num25 && tempMinInt < DwsStrConstant.ins().num25 ){
            return tempMinInt;
        }else if (tempMaxInt > DwsStrConstant.ins().num40 && tempMinInt < DwsStrConstant.ins().num25){
            return tempMinInt;
        }else if (tempMaxInt > DwsStrConstant.ins().num40 && tempMinInt > DwsStrConstant.ins().num40 ){
            return tempMaxInt;
        }else if (tempMaxInt > DwsStrConstant.ins().num40 && tempMinInt >= DwsStrConstant.ins().num25 && tempMinInt <= DwsStrConstant.ins().num40){
            return tempMaxInt;
        }else {
            return null;
        }
    }

    public Integer dcObc(Integer obcConnect,Integer dcConnect){
        if (obcConnect == null && dcConnect == null){
            return null;
        }
        if (obcConnect == null){
            return 0;
        }
        if (dcConnect == null){
            return 1;
        }
        if (obcConnect==0 && dcConnect==1){
            return 0;
        }else if (obcConnect == 1 && dcConnect ==0){
            return 1;
        }else {
            return 2;
        }
    }

    private volatile static ChargePredictStrategy strategy;
    private ChargePredictStrategy(){
    }
    public static ChargePredictStrategy ins() {
        if (strategy == null) {
            synchronized (ChargePredictStrategy.class) {
                if (strategy == null) {
                    strategy = new ChargePredictStrategy();
                }
            }
        }
        return strategy;
    }

}
